package com.zywl.utils.utils.enums;

import com.zywl.utils.utils.Constants;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum LogTypeEnum {
    LOGIN("login", "登录登出"), RESOURCE("resource", "权限管理"), ROLE("role", "角色管理"),
    USER("user", "用户管理"), DICTIONARY("dict", "字典管理"), UNIT("unit", "单位管理"),
    MEMBER("member","会员管理" ), ASSOCIATION("association","协会管理" ), COMPANY("company","公司管理" ),
    DEMAND("demand","需求管理" ), AGREEMENT("agreement", "说明修改"),SETMEAL("setmeal","套餐管理");

    private final String key;
    private final String value;

    LogTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getValueByKey(String key) {
        for (LogTypeEnum en : LogTypeEnum.values()) {
            if (en.getKey().equals(key)) {
                return en.getValue();
            }
        }
        return Constants.STRING_NULL;
    }

    public static String getKeyByValue(String value) {
        for (LogTypeEnum en : LogTypeEnum.values()) {
            if (en.getValue().equalsIgnoreCase(value)) {
                return en.getKey();
            }
        }
        return Constants.STRING_NULL;
    }

    public static List<Map<String, Object>> getListData() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        Map<String, Object> map = null;
        for (LogTypeEnum en : LogTypeEnum.values()) {
            map = new HashMap<String, Object>();
            map.put("key", en.getKey());
            map.put("value", en.getValue());
            list.add(map);
        }
        return list;
    }
}
